package com.api.shopapi.service.impl;

import com.api.shopapi.entity.NursingType;
import com.api.shopapi.mapper.NursingTypeMapper;
import com.api.shopapi.service.NursingTypeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("NursingTypeServiceImplOne")
public class NursingTypeServiceImpl implements NursingTypeService {
    @Autowired
    private NursingTypeMapper nursingTypeMapper;


    @Override
    public int insert(NursingType nursingType) {
        return nursingTypeMapper.insert(nursingType);
    }

    @Override
    public int updateByNursingTypeCode(NursingType nursingType) {
        return nursingTypeMapper.updateByNursingTypeCode(nursingType);
    }

    @Override
    public List<NursingType> getListNursingType(String institutionCode) {
        return nursingTypeMapper.getListNursingType(institutionCode);
    }

    @Override
    public int deleteByNursingTypeCode(String nursingTypeCode) {
        return nursingTypeMapper.deleteByNursingTypeCode(nursingTypeCode);
    }

    @Override
    public NursingType getByNursingTypeCode(String nursingTypeCode) {
        return nursingTypeMapper.getByNursingTypeCode(nursingTypeCode);
    }

    @Override
    public PageInfo<NursingType> getPageInfoNursingType(int pageIndex, int pageSize, String institutionCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<NursingType> listNursingType =nursingTypeMapper.getListNursingType(institutionCode);
        return new PageInfo<>(listNursingType);
    }

    @Override
    public NursingType getByNameAndInstitutionCode(String name, String institutionCode) {
        return nursingTypeMapper.getByNameAndInstitutionCode(name,institutionCode);
    }

    @Override
    public List<NursingType> getList(String institutionCode) {
        return nursingTypeMapper.getList(institutionCode);
    }


    @Override
    public
    PageInfo<NursingType> pageByGovCode(int pageIndex, int pageSize, String governmentCode){
        PageHelper.startPage(pageIndex,pageSize);
        List<NursingType> listNursingType =nursingTypeMapper.listByGovCode(governmentCode);
        return new PageInfo<>(listNursingType);
    }

}
